package org.example.myleet.p1422;

public class Solution {
    public int maxScore(String s) {
        int leftScore = 0, rightScore = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '1') {
                ++rightScore;
            }
        }
        int maxScore = 0;
        for (int i = 0; i < s.length() - 1; ++i) {
            if (s.charAt(i) == '1') {
                --rightScore;
            } else {
                ++leftScore;
            }
            maxScore = Math.max(maxScore, leftScore + rightScore);
        }
        return maxScore;
    }
}
